<?php

/** 
 * 后台进程:充值订单
 * @property Recharge_order_mdl $recharge
 */
class Recharge extends MY_Controller {
	public function __construct() {
		parent::__construct ();
		$this->load->model ( 'Recharge_order_mdl', 'recharge' );
		$this->apiOutput->debug = true;
	}
	public function run(){
		$orders = $this->getUnPayOrders();
		foreach ( $orders as $order ){
			$res = $this->recharge->queryOrderResult($order,TRUE);
		}
	}
	
	private function getUnPayOrders(){
		$time = time();
		return $this->db->select('*')
				->from(MY_Model::T_RECHARGE_ORDER)
				->where_in('tradeState',$this->recharge->needQueryState)// 状态为未查询
				->where('payTime >=',$time - 7200)//只查2小时之内
				->where('payTime <=',$time - 1)//延迟1秒,避免冲突
				->get()
				->result_array();
	}
}

